import React, { Component } from 'react';
class hdref extends Component {
  constructor(props) {
    super(props);
    this.state = {}
  }
  render() {
    return (
      <div>
        <div>
          <input ref={this.onInput1} type="text" placeholder="a内容"></input> &nbsp;&nbsp;
          <button onClick={this.showData1}>获取a</button>  &nbsp;&nbsp;
          {/* 内联ref 跟新过程中会被执行两次 */}
          <input ref={(c) => { this.input2 = c }} onBlur={this.showData2} type="text" placeholder="b内容"></input>
        </div>
      </div>
    );
  }
  onInput1 = (c) => {
    this.input1 = c
  }
  showData1 = () => {
    console.log(this.input1.value)
  }
  showData2 = () => {
    console.log(this.input2.value)
  }
}

export default hdref;